package com.aididi;

import com.aididi.entity.Book;
import com.aididi.interfaces.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
@EnableCaching
public class SpringbootCacheApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringbootCacheApplication.class, args);
	}


	@Autowired
	private BookRepository bookRepository;

	@GetMapping("/hello/{message}")
	public String hi(@PathVariable(name="message")  String message){
		Book book = bookRepository.getByIsbn(message);
		return book.getTitle();
	}

}
